package thread;

import javax.security.auth.callback.Callback;
import java.util.concurrent.*;

public class CallAbleDemoThread {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ThreadPoolExecutor executorService= (ThreadPoolExecutor) Executors.newCachedThreadPool();
        TaskWithResult task=new TaskWithResult(1);
        Future<String> submit = executorService.submit(task);
        String result = submit.get();
        System.out.println(result);
    }

}

class TaskWithResult implements Callable<String> {

    private  int id;

    public TaskWithResult(int id) {
        this.id = id;
    }

    @Override
    public String call() throws Exception {
        System.out.println(Thread.currentThread().getName()+"执行");
        return "result of TaskWithResult "+id;
    }



}